using Microsoft.Xna.Framework;
using ZombieHigh2.Interfaces;
using ZombieHigh2.AI;

namespace ZombieHigh2.Controller
{
    public class BaseAIController : BaseController, AIEvents
    {
        protected PlayerBrain Brain;
        protected Vector3 PlayerLocation;
        protected Vector3 Me;

        public BaseAIController()
            : base()
        {
            Brain = new PlayerBrain();
        }

        public virtual void AI_PlayerLocation(Vector3 me, Vector3 position)
        {
            Me = me;
            PlayerLocation = position;
        }

        public virtual void AI_Damage(int amount)
        {
            Brain.Hit();
        }

        public BaseState GetCurrentState()
        {
            return Brain.GetCurrentState();
        }

        public override ControllerData GetControllerData()
        {
            if (Brain.GetCurrentState() is WalkState)
            {
                ControlData.LAnalog = new Vector2(PlayerLocation.X - Me.X , PlayerLocation.Z - Me.Z);
                ControlData.LAnalog.Normalize();
            }

            return ControlData;
        }

        public virtual void AI_IdleTimeUp()
        {
            Brain.IdleTimeUp();
        }

        public virtual void AI_StunTimeUp()
        {
            Brain.StunTimeUp();
        }

        public virtual void AI_HealthLessThanZero()
        {
            Brain.HealthLessThanZero();
        }
    }
}
